/*
 * @model :  公共方法
 * @author:  W.TBF
 * @time  :  2016/08/12
 */

var common = {

}



// ajaxHelper
function AjaxHelper() {
	this.ajax = function(url, type, dataType, data, callback) {
        $.ajax({
            url: url,
            type: type,
            dataType: dataType,
            data: data,
            success: callback,
            error: function(xhr, errorType, error) {
                alert('Ajax request error, errorType: ' + errorType +  ', error: ' + error)
            }
        });			
	}
};
AjaxHelper.prototype.get = function(url, data, callback) {
    this.ajax(url, 'GET', 'json', data, callback)
};
AjaxHelper.prototype.post = function(url, data, callback) {
    this.ajax(url, 'POST', 'json', data, callback)
};
AjaxHelper.prototype.put = function(url, data, callback) {
    this.ajax(url, 'PUT', 'json', data, callback)
};
AjaxHelper.prototype.delete = function(url, data, callback) {
	this.ajax(url, 'DELETE', 'json', data, callback)
};
AjaxHelper.prototype.jsonp = function(url, data, callback) {
	this.ajax(url, 'GET', 'jsonp', data, callback)
};
AjaxHelper.prototype.constructor = AjaxHelper;




//时间转换 yyyy-MM-dd HH:mm:ss
var formatDate= function formatDateTime(strDate){
	if (strDate!= null && strDate != "") {
	    date=new Date(strDate)
	    var y = date.getFullYear();  //年
	    var m = date.getMonth() + 1;  //月
	    m = m < 10 ? ('0' + m) : m;
	    var d = date.getDate();  //日
	    d = d < 10 ? ('0' + d) : d;
	    var h = date.getHours();  //时
	    h = h < 10 ? ('0' + h) : h;
	    var minute = date.getMinutes(); //分
	    minute = minute < 10 ? ('0' + minute) : minute;
	    var seconds=date.getSeconds(); //秒
	    seconds=seconds<10?('0'+seconds):seconds;
	    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+seconds;
	}
	return "-"
};

//yyyy-MM-dd
var formatDate2= function formatDateTime2(strDate){
   if (strDate!= null && strDate != "") {
       date=new Date(strDate)
       var y = date.getFullYear();  //年
       var m = date.getMonth() + 1;  //月
       m = m < 10 ? ('0' + m) : m;
       var d = date.getDate();  //日
       d = d < 10 ? ('0' + d) : d;
       return y + '-' + m + '-' + d;
   }
   return "-"
};